function contact_init(){
    var email = $('mail');
    var nombre = $('name');
    var body = $('body')
    var submit_button = $('submit_button');

    var name_ok = true;
    var email_ok = false;
    var body_ok = false;


    email.addEvent('blur',function(){
        validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
        strEmail = email.value;
        
        if(strEmail.search(validRegExp) == -1 || email.value.length < 1 || email.value.length > 128)
        {   
            email.highlight('#FF3333');
            email_ok = false;
            $('mail_tip').set('text','El email debe tener entre 1 y 128 caracteres, y debe ser una dirección válida');
        }
        else
        {
            email_ok = true;     
            $('mail_tip').set('text','');
        }
        if( name_ok && body_ok && email_ok){
            submit_button.set('disabled',false);    
        } else {
            submit_button.set('disabled',true);    
        }
    });
    
    email.addEvent('keydown',function(){
        validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
        strEmail = email.value;
        
        if(strEmail.search(validRegExp) == -1 || email.value.length < 1 || email.value.length > 128)
        {   
            email_ok = false;
            if(email.value.length+1>128){
                return false;
            }
        }
        else
        {
            email_ok = true;     
        }
        if( name_ok && body_ok && email_ok){
            submit_button.set('disabled',false);    
        } else {
            submit_button.set('disabled',true);    
        }
    });
    
    body.addEvent('blur',function(){
        
        if(body.value.length < 1 || body.value.length > 3000)
        {   
            body.highlight('#FF3333');
            body_ok = false;
            $('body_tip').set('text','La consulta es obligatoria es obligatoria');
        }
        else
        {
            body_ok = true;     
            $('body_tip').set('text','');
        }
        if( name_ok && body_ok && email_ok){
            submit_button.set('disabled',false);    
        } else {
            submit_button.set('disabled',true);    
        }
    });
    
    body.addEvent('keydown',function(key){
        if(body.value.length < 1 || body.value.length > 3000)
        {   
            if(body.value.length+1>3000){
                return false;
            }
        }
        else
        {
            body_ok = true;     
        }
        if( name_ok && body_ok && email_ok){
            submit_button.set('disabled',false);    
        } else {
            submit_button.set('disabled',true);    
        }
    });
    
    nombre.addEvent('keydown',function(){
        if(nombre.value.length < 1 || nombre.value.length > 100)
        {   
            if(nombre.value.length+1>100){
                return false;
            }
        }
        if( name_ok && body_ok && email_ok){
            submit_button.set('disabled',false);    
        } else {
            submit_button.set('disabled',true);    
        }
    });
    

    email.fireEvent('keydown');
    body.fireEvent('keydown');

}

function init(){
    contact_init();
}